#include <xml/Stream.h>

struct b2Vec2;

namespace physics
{

template <class T>
class ValueLoader: public xml::ObjectANSI
{		
protected:
		
	bool on_attribute(xml::Provider *prov, const std::string &name, const std::string &value)
	{
		if(name == "Value")
			return converter::convert(value, &val);

		return false;
	}

public:
	ValueLoader() {}

	const T& GetValue() const { return val; }

private:
	T val;
};

class ValueReader
{
public:
	template <typename T> static bool Read(xml::Provider *provider, T& value);
};

template <typename T> inline bool ValueReader::Read(xml::Provider *provider, T& value)
{
	ValueLoader <T> loader;
	if(!provider->parse_object(&loader))
		return false;

	value = loader.GetValue();
	return true;
}

template <> bool ValueReader::Read <b2Vec2>(xml::Provider *provider, b2Vec2& value);
	
}